package com.hydra.base.entity;

import com.baomidou.mybatisplus.annotation.TableField;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.hydra.base.comment.Comment;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import org.springframework.data.annotation.CreatedBy;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedBy;
import org.springframework.data.annotation.LastModifiedDate;

import java.time.LocalDateTime;
import java.util.Date;

@ToString
public class UserTimeEntity extends IdEntity implements UserTimeInterface, DelFlagInterface {

	@Getter @Setter
	@Comment("删除标志，1：删除，0：正常")
	protected boolean delFlag = false;

	@Getter @Setter
	@CreatedBy
	@Comment("创建人ID")
	protected String creator;

	@Getter @Setter
	@CreatedBy
	@Comment("创建人名称")
	@TableField(exist = false)
	protected String creatorName;

	@Getter @Setter
	@CreatedBy
	@Comment("更新人名称")
	@TableField(exist = false)
	protected String updaterName;

	@Getter @Setter
	@LastModifiedBy
	@Comment("更新人ID")
	protected String updater;

	@Getter @Setter
	@CreatedDate
	@Comment("创建时间")
	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
	protected LocalDateTime createTime;

	@Getter @Setter
	@LastModifiedDate
	@Comment("更新时间")
	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
	protected LocalDateTime updateTime;

	public void initEntity(){
		this.createTime = LocalDateTime.now();
		this.updateTime = LocalDateTime.now();
		this.delFlag = false;
	}

}
